﻿using System;

using System.Collections.Generic;
using System.Text;
using Silvermoon.Controls;
using System.Drawing;
using Silvermoon.Utils;
using Silvermoon.OpenGL;
using Silvermoon.Visuals;
using Silvermoon;
using Silvermoon.Animations;
using Silvermoon.Images;

namespace FileExplorer
{
    public class CalcButton : Button
    {
        private readonly Color glowColor = Color.FromArgb(20, 172, 255);
        private RotateTransform rotate;
        private TranslateTransform translate;
        private Color origColor;
        private Color origTextColor;
      //  private Animation animation;

        public CalcButton()
            : base()
        {
            Font = FontSprite.Bold;
            Style = RenderStyle.Chrome;
            translate = new TranslateTransform();
            rotate = new RotateTransform { Axis = RotateAxis.XAxis, Angle = 0f };
            Transformations = new Transformation[] { translate, rotate };
        }

        public int WaveOffset { get; set; }

        public float ZOffset { get { return translate.OffsetZ; } set { if (translate.OffsetZ != value) { translate.OffsetZ = value; Invalidate(InvalidationFlag.Appearance); } } }

        protected float XAngle
        {
            get { return rotate.Angle; }
            set
            {
                rotate.Angle = value; Invalidate(InvalidationFlag.Appearance);
            }
        }

        protected override void OnPressedChanged()
        {
            if (origColor.IsEmpty) origColor = Color;
            if (origTextColor.IsEmpty) origTextColor = TextColor;
            base.OnPressedChanged();
            Color = IsPressed ? ColorUtil.AlphaBlendColor(origColor, Color.White, 100) : origColor;
            TextColor = IsPressed ? Color.White : origTextColor;
            Texture = IsPressed ? SysImages.GlowButton : SysImages.Button;
        }

        protected override void OnClick()
        {
            //if (animation != null) animation.Abort();
            //int start = ((int)XAngle % 360);
            //int end = Math.Min(360, start + 360);

            //animation = new Animation(1500, start, end, 0);
            //animation.Acceleration = 1.5f;
            //animation.Progress += (s, e) => XAngle = (float)e.Value;
            //animation.InvokeAsync();
            base.OnClick();
        }
    }
}
